<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>


    <title>用户注册</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <link rel="stylesheet" href="css/list.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script src="js/jq-paginator.js"></script>


    <style>
        /* 基础样式 */
        :root {
            --primary-color: #007bff;
            --secondary-color: #6c757d;
            --accent-color: #28a745;
            --bg-gradient: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: var(--bg-gradient);
            margin: 0;
            padding: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .container {
            width: 100%;
            max-width: 450px;
            padding: 30px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
            animation: fadeIn 0.6s ease-in-out;
            margin-top: 70px; /* 为导航栏留出空间 */
        }

        @keyframes fadeIn {
            from {opacity: 0; transform: translateY(10px);}
            to {opacity: 1; transform: translateY(0);}
        }

        h2 {
            text-align: center;
            color: #1a1a1a;
            margin-bottom: 25px;
            font-size: 1.8rem;
            font-weight: 600;
            letter-spacing: 1px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #333;
            font-size: 0.95rem;
        }

        input[type="text"],
        input[type="email"],
        input[type="password"],
        input[type="tel"] {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #e0e0e0;
            border-radius: 6px;
            font-size: 1rem;
            transition: all 0.3s ease;
            box-sizing: border-box;
            outline: none;
        }

        input[type="text"]:focus,
        input[type="email"]:focus,
        input[type="password"]:focus,
        input[type="tel"]:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
        }

        /* 性别单选样式优化 */
        .gender-group {
            display: flex;
            gap: 20px;
        }

        .gender-option {
            display: flex;
            align-items: center;
            gap: 5px;
            cursor: pointer;
        }

        .gender-option input[type="radio"] {
            appearance: none;
            width: 20px;
            height: 20px;
            border: 2px solid #ccc;
            border-radius: 50%;
            outline: none;
            transition: border-color 0.3s ease;
        }

        .gender-option input[type="radio"]:checked {
            border-color: var(--primary-color);
            background: var(--primary-color);
        }

        .gender-option input[type="radio"]:checked::after {
            content: '';
            display: block;
            width: 10px;
            height: 10px;
            margin: 3px auto;
            background: white;
            border-radius: 50%;
        }

        /* 按钮样式 */
        button {
            width: 100%;
            padding: 12px;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        button:hover {
            background: #0056b3;
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        button:active {
            transform: translateY(0);
        }

        /* 登录链接 */
        .login-link {
            text-align: center;
            margin-top: 20px;
            font-size: 0.9rem;
            color: #666;
        }

        .login-link a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s ease;
        }

        .login-link a:hover {
            color: #0056b3;
            text-decoration: underline;
        }

        /* 表单验证提示 */
        .form-group input:invalid:focus {
            border-color: #dc3545;
            box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
        }

        @media (max-width: 500px) {
            .gender-group {
                flex-direction: column;
                gap: 10px;
            }
        }

        /* 导航栏样式 */
        .nav {
            width: 100%;
            display: flex;
            align-items: center;
            padding: 15px 50px;
            background: white;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
            position: fixed;
            top: 0;
            z-index: 10;
        }

        .nav-logo {
            height: 50px;
            width: 50px;
            border-radius: 50%;
            background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            font-weight: bold;
            margin-right: 15px;
            box-shadow: 0 3px 10px rgba(13, 110, 253, 0.3);
        }

        .nav-title {
            color: #0d6efd;
            font-size: 1.5rem;
            font-weight: 700;
            letter-spacing: 0.5px;
        }

        .nav-links {
            display: flex;
            align-items: center;
            margin-left: auto;
            gap: 15px;
        }

        .nav-link-custom {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            color: #555;
            text-decoration: none;
            font-weight: 500;
            border-radius: 6px;
            transition: all 0.3s ease;
        }

        .nav-link-custom i {
            margin-right: 6px;
            font-size: 1rem;
            transition: transform 0.3s ease;
        }

        .nav-link-custom:hover {
            background: rgba(13, 110, 253, 0.08);
            color: #0d6efd;
        }

        .nav-link-custom:hover i {
            transform: scale(1.1);
        }

        .user-dropdown {
            position: relative;
            margin-left: 10px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            color: #555;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.3s ease;
        }

        .user-info:hover {
            background: rgba(13, 110, 253, 0.08);
            color: #0d6efd;
        }

        .user-info i {
            margin-right: 8px;
            font-size: 1.2rem;
        }

        .user-dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            width: 200px;
            background: white;
            border-radius: 8px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
            padding: 10px 0;
            margin-top: 5px;
            opacity: 0;
            visibility: hidden;
            transform: translateY(10px);
            transition: all 0.3s ease;
            z-index: 1000;
        }

        .user-dropdown:hover .user-dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .user-dropdown-menu::before {
            content: '';
            position: absolute;
            top: -8px;
            right: 20px;
            width: 16px;
            height: 16px;
            background: white;
            transform: rotate(45deg);
        }

        .user-dropdown-item {
            display: flex;
            align-items: center;
            padding: 10px 20px;
            color: #333;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .user-dropdown-item i {
            margin-right: 10px;
            color: #0d6efd;
            font-size: 1rem;
        }

        .user-dropdown-item:hover {
            background: #f0f7ff;
            color: #0d6efd;
        }
    </style>
</head>
<body>

<!-- 导航栏 -->
<nav class="nav">
    <div class="nav-logo">
        <img src="pic/logo2.jpg" alt="医院系统Logo">
    </div>
    <span class="nav-title">医院挂号系统</span>

    <div class="nav-links">
        <a class="nav-link-custom" onclick="pl()">
            <i class="bi bi-house-door"></i>主页
        </a>
        <a class="nav-link-custom" onclick="pl()">
            <i class="bi bi-calendar-plus"></i>快速挂号
        </a>

        <div class="user-dropdown">
            <div class="user-info">
                <i class="bi bi-person-circle"></i>
                <span>当前用户</span>
            </div>

            <div class="user-dropdown-menu">
                <a class="user-dropdown-item" onclick="pl()">
                    <i class="bi bi-person-badge"></i>个人资料
                </a>
                <a class="user-dropdown-item" onclick="pl()">
                    <i class="bi bi-calendar-check"></i>我的挂号
                </a>
                <a class="user-dropdown-item" onclick="pl()">
                    <i class="bi bi-box-arrow-right"></i>退出登录
                </a>
            </div>
        </div>
    </div>
</nav>

<div class="container">
    <h2>用户注册</h2>
    <form id="registerForm">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" required
                   pattern="^[a-zA-Z0-9_\u4e00-\u9fa5]{3,20}$"
                   title="3-20位中英文、数字或下划线">
        </div>

        <div class="form-group">
            <label>性别</label>
            <div class="gender-group">
                <label class="gender-option">
                    <input type="radio" name="gender" value="1" required>
                    男
                </label>
                <label class="gender-option">
                    <input type="radio" name="gender" value="2" required>
                    女
                </label>
            </div>
        </div>

        <div class="form-group">
            <label for="phone">联系电话</label>
            <input type="tel" id="phone" name="phone">
        </div>

        <div class="form-group">
            <label for="address">住址</label>
            <input type="text" id="address" name="address"
                   placeholder="省/市/区+详细地址">
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password">
        </div>

        <div class="form-group">
            <label for="confirmPassword">确认密码</label>
            <input type="password" id="confirmPassword" name="confirmPassword" required>
        </div>

        <button type="submit" onclick="enroll()">注册</button>
    </form>

    <div class="login-link">
        已有账号？<a href="gh_login.html">立即登录</a>
    </div>
</div>

<script src="js/jquery.min.js"></script>
<script>




    function pl(){
        alert("请先完成登录")
    }


    function enroll(){

        const username = $('#username').val().trim();
        const gender = $('input[name="gender"]:checked').val();
        const phone = $('#phone').val().trim();
        const address = $('#address').val().trim();
        const password = $('#password').val();
        const confirmPassword = $('#confirmPassword').val();

    // 验证函数示例
        if (!username) {
            alert("用户名不能把为空")
            return ;
        }

        if (!gender) {
            alert('请选择性别');
            return ;
        }

        if (!phone) {
            alert("联系电话不能为空");
            return ;
        }

        if (!address) {
            alert("地址不能为空");
            return ;
        }


        if (!password) {
            alert("密码不能为空 ")
            return ;
        }

        if (password !== confirmPassword) {
            alert('两次输入的密码不一致！');
            return;
        }




        // 发送AJAX请求
        $.ajax({
            type: "POST",
            url: "user/enroll",
            data: {
                username: username,
                gender:gender,
                password: password,
                phone :phone,
                address:address,
                password:password,
            },
            success: function(result) {

                console.log(result)
                if ( result ==="注册成功") {
                    console.log("111")
                    alert(result);
                    location.href = "gh_login.html";
                }else {
                    console.log(result)
                    alert(result);
                }
            },
            error:function (error){
                console.log(error)
            }
        });
    }
</script>
</body>
</html>